package com.test.jmx.agent;

import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;

public class HelloWorld extends NotificationBroadcasterSupport implements HelloWorldMBean {

	private String greeting = null;

	public HelloWorld() {
		this.greeting = "Hello World! I'm a stand MBean.";
	}

	@Override
	public String getGreeting() {
		return this.greeting;
	}

	@Override
	public void greeting() {
		System.out.println(greeting);
	}

	@Override
	public void setGreeting(String greeting) {
		this.greeting = greeting;
		Notification notification = new Notification("jmxbook.ch2.helloWorld.test", this, -1, System.currentTimeMillis(), greeting);
		sendNotification(notification);
	}

	@Override
	public void exit() {
		System.out.println("I'm going to exit...");
		System.exit(0);
	}

}
